package com.health.fragment.tijian;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import com.health.NovaApplication;
import com.health.PersonalFileActivity.onFragmentSave;
import com.health.R;
import com.health.adapter.RadioButtonAdapter;
import com.health.db.FDbManager;
import com.health.fragment.NovaFragment;
import com.health.tablebean.ARCHIVE_BASEINFO;
import com.health.tablebean.ARCHIVE_FAMILYBEDHISTORY;
import com.health.tablebean.ARCHIVE_HOSPITALHISTORY;
import com.health.tablebean.ARCHIVE_MEDICATION;
import com.health.tablebean.BD_DD_INFO;
import com.health.activity.tijian.TiJianActivity;
import com.health.tools.GlobalConts;
import com.health.view.spinner.NiceSpinner;
import com.health.view.spinner.NiceSpinnerAdapter;
import com.health.widget.EditTextWithDate;
import com.health.widget.MyGridView;

import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;

/**
 * 健康体检--治疗情况
 * 
 * @author nova
 *
 */
public class HealthTiJian_ZLQKFragment extends NovaFragment implements onFragmentSave {

	private MyGridView gd_yy1_fyycx;
	private MyGridView gd_yy2_fyycx;
	private MyGridView gd_yy3_fyycx;
	private MyGridView gd_yy4_fyycx;
	private MyGridView gd_yy5_fyycx;
	private MyGridView gd_yy6_fyycx;
	private RadioButtonAdapter adapter_yy1_fyycx = null;
	private RadioButtonAdapter adapter_yy2_fyycx = null;
	private RadioButtonAdapter adapter_yy3_fyycx = null;
	private RadioButtonAdapter adapter_yy4_fyycx = null;
	private RadioButtonAdapter adapter_yy5_fyycx = null;
	private RadioButtonAdapter adapter_yy6_fyycx = null;

	private EditTextWithDate ed_time1_start;
	private EditTextWithDate ed_time1_end;

	private EditText ed_time1_result;
	private EditText ed_time1_yljg;
	private EditText ed_time1_bah;
	private EditTextWithDate ed_time2_start;
	private EditTextWithDate ed_time2_end;

	private EditText ed_time2_result;
	private EditText ed_time2_yljg;
	private EditText ed_time2_bah;

	private EditTextWithDate ed_jt_time1_start;
	private EditTextWithDate ed_jt_time1_end;
	private EditText ed_jt_time1_result;
	private EditText ed_jt_time1_yljg;
	private EditText ed_jt_time1_bah;
	private EditTextWithDate ed_jt_time2_start;
	private EditTextWithDate ed_jt_time2_end;
	private EditText ed_jt_time2_result;
	private EditText ed_jt_time2_yljg;
	private EditText ed_jt_time2_bah;

	private EditText ed_yy1_ywmc;
	private EditText ed_yy1_yf;
	private EditText ed_yy1_yl;

	private EditText ed_yy2_ywmc;
	private EditText ed_yy2_yf;
	private EditText ed_yy2_yl;

	private EditText ed_yy3_ywmc;
	private EditText ed_yy3_yf;
	private EditText ed_yy3_yl;

	private EditText ed_yy4_ywmc;
	private EditText ed_yy4_yf;
	private EditText ed_yy4_yl;

	private EditText ed_yy5_ywmc;
	private EditText ed_yy5_yf;
	private EditText ed_yy5_yl;

	private EditText ed_yy6_ywmc;
	private EditText ed_yy6_yf;
	private EditText ed_yy6_yl;

	private List<String> lstYy;
	private NiceSpinner nice_spinner_yy1_yysj;
	private NiceSpinner nice_spinner_yy2_yysj;
	private NiceSpinner nice_spinner_yy3_yysj;
	private NiceSpinner nice_spinner_yy4_yysj;
	private NiceSpinner nice_spinner_yy5_yysj;
	private NiceSpinner nice_spinner_yy6_yysj;

	NiceSpinnerAdapter<BD_DD_INFO> nice_adapter_yy1_yysj = null;
	NiceSpinnerAdapter<BD_DD_INFO> nice_adapter_yy2_yysj = null;
	NiceSpinnerAdapter<BD_DD_INFO> nice_adapter_yy3_yysj = null;
	NiceSpinnerAdapter<BD_DD_INFO> nice_adapter_yy4_yysj = null;
	NiceSpinnerAdapter<BD_DD_INFO> nice_adapter_yy5_yysj = null;
	NiceSpinnerAdapter<BD_DD_INFO> nice_adapter_yy6_yysj = null;

	private View healthQuesView = null;
	private FDbManager fdbmanger = null;
	private String str_yy1_fyycxId = "";
	private String str_yy2_fyycxId = "";

	private String str_yy3_fyycxId = "";
	private String str_yy4_fyycxId = "";
	private String str_yy5_fyycxId = "";
	private String str_yy6_fyycxId = "";

	private int from_zy = -1;// from ==1 从基本信息数据库处理 from ==0 第一次保存
	private int from_yy = -1;// 用药 from ==1 从基本信息数据库处理 from ==0 第一次保存
	private int from_jtbcs = -1;// from ==1 从基本信息数据库处理 from ==0 第一次保存

	private ARCHIVE_BASEINFO userInfo;// 基本信息
	private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
	private ARCHIVE_MEDICATION ques1_before = new ARCHIVE_MEDICATION();
	private ARCHIVE_MEDICATION ques2_before = new ARCHIVE_MEDICATION();
	private ARCHIVE_MEDICATION ques3_before = new ARCHIVE_MEDICATION();
	private ARCHIVE_MEDICATION ques4_before = new ARCHIVE_MEDICATION();
	private ARCHIVE_MEDICATION ques5_before = new ARCHIVE_MEDICATION();
	private ARCHIVE_MEDICATION ques6_before = new ARCHIVE_MEDICATION();

	private ARCHIVE_HOSPITALHISTORY zy1_before = new ARCHIVE_HOSPITALHISTORY();
	private ARCHIVE_HOSPITALHISTORY zy2_before = new ARCHIVE_HOSPITALHISTORY();

	private ARCHIVE_FAMILYBEDHISTORY family_zy1_before = new ARCHIVE_FAMILYBEDHISTORY();
	private ARCHIVE_FAMILYBEDHISTORY family_zy2_before = new ARCHIVE_FAMILYBEDHISTORY();

	@Override
	public View findViews(LayoutInflater inflater) {
		fdbmanger = NovaApplication.fdbmanger;
		userInfo = NovaApplication.getUserInfo();
		healthQuesView = inflater.inflate(R.layout.healthtijian_zlqk_fragment, null);
		initViews(healthQuesView);
		lstYy = new ArrayList<String>();

		// TODO ed_time1_bah; 病案号没找到字段
		// TODO ed_time2_bah;
		GlobalConts.setMaxLength(50, ed_time1_result, ed_time2_result, ed_jt_time1_result, ed_jt_time2_result);
		GlobalConts.setMaxLength(10, ed_time1_yljg, ed_time2_yljg, ed_jt_time1_yljg, ed_jt_time2_yljg);
		GlobalConts.setMaxLength(20, ed_time1_bah, ed_time2_bah, ed_jt_time1_bah, ed_jt_time2_bah);
		// 药物名称
		GlobalConts.setMaxLength(35, ed_yy1_ywmc, ed_yy2_ywmc, ed_yy3_ywmc, ed_yy4_ywmc, ed_yy5_ywmc, ed_yy6_ywmc);

		GlobalConts.setMaxLength(10, ed_yy1_yf, ed_yy2_yf, ed_yy3_yf, ed_yy4_yf, ed_yy5_yf, ed_yy6_yf); // 用法
		GlobalConts.setMaxLength(10, ed_yy1_yl, ed_yy2_yl, ed_yy3_yl, ed_yy4_yl, ed_yy5_yl, ed_yy6_yl); // 用量

		String[] yys = new String[] { "一个月", "三个月", "六个月", "一年", "两年", "三年", "四年", "五年", "六年", "七年", "八年", "九年", "十年",
				"十五年", "二十年", "二十五年", "三十年", "四十年", "五十年", "六十年", "七十年", "八十年" };
		for (String yy : yys) {
			lstYy.add(yy);
		}
		return healthQuesView;
	}

	@Override
	public void setupView(View view) {

	}

	@Override
	public void addListener() {

	}

	@Override
	public void setData() {
		// //脑血管疾病 PARENTID='DM100-26'
		// //肾脏疾病 PARENTID='DM100-27'
		// //心脏疾病 PARENTID='DM100-28'
		// //血管疾病 PARENTID='DM100-29'
		// //眼部疾病 PARENTID='DM100-30'
		// 神经系统 PARENTID='DM100-31'
		bindDdata("服药依从性", "PARENTID='DM01-70'");

		bindSpinner("用药时间", "PARENTID='DM100-36'");
		setShowData();

	}

	/**
	 * 初始化布局
	 * 
	 * @param v
	 * @author 王婷婷
	 * @date 2015年12月17日 上午10:13:55
	 */
	private void initViews(View v) {
		gd_yy1_fyycx = (MyGridView) v.findViewById(R.id.gd_yy1_fyycx);
		gd_yy2_fyycx = (MyGridView) v.findViewById(R.id.gd_yy2_fyycx);
		gd_yy3_fyycx = (MyGridView) v.findViewById(R.id.gd_yy3_fyycx);
		gd_yy4_fyycx = (MyGridView) v.findViewById(R.id.gd_yy4_fyycx);
		gd_yy5_fyycx = (MyGridView) v.findViewById(R.id.gd_yy5_fyycx);
		gd_yy6_fyycx = (MyGridView) v.findViewById(R.id.gd_yy6_fyycx);

		ed_time1_start = (EditTextWithDate) v.findViewById(R.id.ed_time1_start);
		ed_time1_end = (EditTextWithDate) v.findViewById(R.id.ed_time1_end);

		ed_time1_result = (EditText) v.findViewById(R.id.ed_time1_result);
		ed_time1_result.setGravity(Gravity.LEFT);
		ed_time1_yljg = (EditText) v.findViewById(R.id.ed_time1_yljg);
		ed_time1_yljg.setGravity(Gravity.LEFT);
		ed_time1_bah = (EditText) v.findViewById(R.id.ed_time1_bah);
		ed_time1_bah.setGravity(Gravity.LEFT);
		ed_time2_start = (EditTextWithDate) v.findViewById(R.id.ed_time2_start);
		ed_time2_end = (EditTextWithDate) v.findViewById(R.id.ed_time2_end);

		ed_time2_result = (EditText) v.findViewById(R.id.ed_time2_result);
		ed_time2_yljg = (EditText) v.findViewById(R.id.ed_time2_yljg);
		ed_time2_bah = (EditText) v.findViewById(R.id.ed_time2_bah);

		ed_jt_time1_start = (EditTextWithDate) v.findViewById(R.id.ed_jt_time1_start);
		ed_jt_time1_end = (EditTextWithDate) v.findViewById(R.id.ed_jt_time1_end);
		ed_jt_time1_result = (EditText) v.findViewById(R.id.ed_jt_time1_result);
		ed_jt_time1_yljg = (EditText) v.findViewById(R.id.ed_jt_time1_yljg);
		ed_jt_time1_bah = (EditText) v.findViewById(R.id.ed_jt_time1_bah);
		ed_jt_time2_start = (EditTextWithDate) v.findViewById(R.id.ed_jt_time2_start);
		ed_jt_time2_end = (EditTextWithDate) v.findViewById(R.id.ed_jt_time2_end);
		ed_jt_time2_result = (EditText) v.findViewById(R.id.ed_jt_time2_result);
		ed_jt_time2_yljg = (EditText) v.findViewById(R.id.ed_jt_time2_yljg);
		ed_jt_time2_bah = (EditText) v.findViewById(R.id.ed_jt_time2_bah);

		ed_yy1_ywmc = (EditText) v.findViewById(R.id.ed_yy1_ywmc);
		ed_yy1_yf = (EditText) v.findViewById(R.id.ed_yy1_yf);
		ed_yy1_yl = (EditText) v.findViewById(R.id.ed_yy1_yl);

		ed_yy2_ywmc = (EditText) v.findViewById(R.id.ed_yy2_ywmc);
		ed_yy2_yf = (EditText) v.findViewById(R.id.ed_yy2_yf);
		ed_yy2_yl = (EditText) v.findViewById(R.id.ed_yy2_yl);

		ed_yy3_ywmc = (EditText) v.findViewById(R.id.ed_yy3_ywmc);
		ed_yy3_yf = (EditText) v.findViewById(R.id.ed_yy3_yf);
		ed_yy3_yl = (EditText) v.findViewById(R.id.ed_yy3_yl);

		ed_yy4_ywmc = (EditText) v.findViewById(R.id.ed_yy4_ywmc);
		ed_yy4_yf = (EditText) v.findViewById(R.id.ed_yy4_yf);
		ed_yy4_yl = (EditText) v.findViewById(R.id.ed_yy4_yl);

		ed_yy5_ywmc = (EditText) v.findViewById(R.id.ed_yy5_ywmc);
		ed_yy5_yf = (EditText) v.findViewById(R.id.ed_yy5_yf);
		ed_yy5_yl = (EditText) v.findViewById(R.id.ed_yy5_yl);

		ed_yy6_ywmc = (EditText) v.findViewById(R.id.ed_yy6_ywmc);
		ed_yy6_yf = (EditText) v.findViewById(R.id.ed_yy6_yf);
		ed_yy6_yl = (EditText) v.findViewById(R.id.ed_yy6_yl);

		nice_spinner_yy1_yysj = (NiceSpinner) v.findViewById(R.id.nice_spinner_yy1_yysj);
		nice_spinner_yy2_yysj = (NiceSpinner) v.findViewById(R.id.nice_spinner_yy2_yysj);
		nice_spinner_yy3_yysj = (NiceSpinner) v.findViewById(R.id.nice_spinner_yy3_yysj);
		nice_spinner_yy4_yysj = (NiceSpinner) v.findViewById(R.id.nice_spinner_yy4_yysj);
		nice_spinner_yy5_yysj = (NiceSpinner) v.findViewById(R.id.nice_spinner_yy5_yysj);
		nice_spinner_yy6_yysj = (NiceSpinner) v.findViewById(R.id.nice_spinner_yy6_yysj);
		ed_time1_start.setBefore(new Date());
		ed_time2_start.setBefore(new Date());

		ed_jt_time1_start.setBefore(new Date());
		ed_jt_time2_start.setBefore(new Date());
		GlobalConts.checkDateAfter(ed_time1_start, ed_time1_end);
		GlobalConts.checkDateAfter(ed_time2_start, ed_time2_end);
		GlobalConts.checkDateAfter(ed_jt_time1_start, ed_jt_time1_end);
		GlobalConts.checkDateAfter(ed_jt_time2_start, ed_jt_time2_end);

		ed_time2_result.setGravity(Gravity.LEFT);
		ed_time2_yljg.setGravity(Gravity.LEFT);
		ed_time2_bah.setGravity(Gravity.LEFT);
		ed_jt_time1_result.setGravity(Gravity.LEFT);
		ed_jt_time1_yljg.setGravity(Gravity.LEFT);
		ed_jt_time1_bah.setGravity(Gravity.LEFT);
		ed_jt_time2_result.setGravity(Gravity.LEFT);
		ed_jt_time2_yljg.setGravity(Gravity.LEFT);
		ed_jt_time2_bah.setGravity(Gravity.LEFT);
		ed_yy1_ywmc.setGravity(Gravity.LEFT);
		ed_yy1_yf.setGravity(Gravity.LEFT);
		ed_yy1_yl.setGravity(Gravity.LEFT);
		ed_yy2_ywmc.setGravity(Gravity.LEFT);
		ed_yy2_yf.setGravity(Gravity.LEFT);
		ed_yy2_yl.setGravity(Gravity.LEFT);
		ed_yy3_ywmc.setGravity(Gravity.LEFT);
		ed_yy3_yf.setGravity(Gravity.LEFT);
		ed_yy3_yl.setGravity(Gravity.LEFT);
		ed_yy4_ywmc.setGravity(Gravity.LEFT);
		ed_yy4_yf.setGravity(Gravity.LEFT);
		ed_yy4_yl.setGravity(Gravity.LEFT);
		ed_yy5_ywmc.setGravity(Gravity.LEFT);
		ed_yy5_yf.setGravity(Gravity.LEFT);
		ed_yy5_yl.setGravity(Gravity.LEFT);
		ed_yy6_ywmc.setGravity(Gravity.LEFT);
		ed_yy6_yf.setGravity(Gravity.LEFT);
		ed_yy6_yl.setGravity(Gravity.LEFT);

	}

	/**
	 * 绑定数据值
	 * 
	 * @param str_where
	 * @param flag
	 * @author 王婷婷
	 * @date 2015年12月17日 上午10:30:30
	 */
	private void bindDdata(String flag, String str_where) {
		List<BD_DD_INFO> listZZs = fdbmanger.findAllByWhereInInfoDB(BD_DD_INFO.class, str_where);

		if (flag.equals("服药依从性")) {

			adapter_yy1_fyycx = new RadioButtonAdapter(listZZs, getActivity());
			gd_yy1_fyycx.setAdapter(adapter_yy1_fyycx);
			adapter_yy2_fyycx = new RadioButtonAdapter(listZZs, getActivity());
			gd_yy2_fyycx.setAdapter(adapter_yy2_fyycx);
			adapter_yy3_fyycx = new RadioButtonAdapter(listZZs, getActivity());
			gd_yy3_fyycx.setAdapter(adapter_yy3_fyycx);
			adapter_yy4_fyycx = new RadioButtonAdapter(listZZs, getActivity());
			gd_yy4_fyycx.setAdapter(adapter_yy4_fyycx);
			adapter_yy5_fyycx = new RadioButtonAdapter(listZZs, getActivity());
			gd_yy5_fyycx.setAdapter(adapter_yy5_fyycx);
			adapter_yy6_fyycx = new RadioButtonAdapter(listZZs, getActivity());
			gd_yy6_fyycx.setAdapter(adapter_yy6_fyycx);

		}
	}

	/**
	 * 获取单选结果
	 * 
	 * @author 王婷婷
	 * @date 2015年12月16日 下午3:10:48
	 */
	private void getRadioButtonCheckedData() {

		str_yy1_fyycxId = adapter_yy1_fyycx.getChecked();
		str_yy2_fyycxId = adapter_yy2_fyycx.getChecked();
		str_yy3_fyycxId = adapter_yy3_fyycx.getChecked();
		str_yy4_fyycxId = adapter_yy4_fyycx.getChecked();
		str_yy5_fyycxId = adapter_yy5_fyycx.getChecked();
		str_yy6_fyycxId = adapter_yy6_fyycx.getChecked();
		Log.w("eeeeeeeee-----", str_yy1_fyycxId + "\n" + str_yy2_fyycxId);

	}

	/**
	 * 保存数据
	 * 
	 * @author 王婷婷
	 * @date 2015年12月17日 上午11:13:39
	 */
	private void saveData() {
		if (checkData()) {
			save_zys();
			save_yyqk();
			save_jtbcs();

		}
	}

	/**
	 * @return 有缺项值 false 无缺项值 true
	 */
	private boolean checkData() {
		if (CheckDate1(ed_time1_start, ed_time1_end, ed_time1_result, ed_time1_yljg, ed_time1_bah)) {
			((TiJianActivity) getActivity()).showTextDialog("请将住院史信息填写完整");
			return false;
		} else {
			if (CheckDate1(ed_time2_start, ed_time2_end, ed_time2_result, ed_time2_yljg, ed_time2_bah)) {
				((TiJianActivity) getActivity()).showTextDialog("请将住院史信息填写完整");
				return false;
			} else {
				if (CheckDate1(ed_jt_time1_start, ed_jt_time1_end, ed_jt_time1_result, ed_jt_time1_yljg,
						ed_jt_time1_bah)) {
					((TiJianActivity) getActivity()).showTextDialog("请将家庭病床史信息填写完整");
					return false;
				} else {
					if (CheckDate1(ed_jt_time2_start, ed_jt_time2_end, ed_jt_time2_result, ed_jt_time2_yljg,
							ed_jt_time2_bah)) {
						((TiJianActivity) getActivity()).showTextDialog("请将家庭病床史信息填写完整");
						return false;
					} else {
						if (CheckDate2(ed_yy1_ywmc, ed_yy1_yf, ed_yy1_yl, adapter_yy1_fyycx)) {
							((TiJianActivity) getActivity()).showTextDialog("请将用药情况填写完整");
							return false;
						} else {
							if (CheckDate2(ed_yy2_ywmc, ed_yy2_yf, ed_yy2_yl, adapter_yy2_fyycx)) {
								((TiJianActivity) getActivity()).showTextDialog("请将用药情况填写完整");
								return false;
							} else {
								if (CheckDate2(ed_yy3_ywmc, ed_yy3_yf, ed_yy3_yl, adapter_yy3_fyycx)) {
									((TiJianActivity) getActivity()).showTextDialog("请将用药情况填写完整");
									return false;
								} else {
									if (CheckDate2(ed_yy4_ywmc, ed_yy4_yf, ed_yy4_yl, adapter_yy4_fyycx)) {
										((TiJianActivity) getActivity()).showTextDialog("请将用药情况填写完整");
										return false;
									} else {
										if (CheckDate2(ed_yy5_ywmc, ed_yy5_yf, ed_yy5_yl, adapter_yy5_fyycx)) {
											((TiJianActivity) getActivity()).showTextDialog("请将用药情况填写完整");
											return false;
										} else {
											if (CheckDate2(ed_yy6_ywmc, ed_yy6_yf, ed_yy6_yl, adapter_yy6_fyycx)) {
												((TiJianActivity) getActivity()).showTextDialog("请将用药情况填写完整");
												return false;
											} else {
												return true;
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}

	/**
	 * 判断住院史和家庭病床史 是否有缺项值
	 * 
	 * @param et1
	 * @param et2
	 * @param et3
	 * @param et4
	 * @param et5
	 * @return true 有缺项值 false 无缺项值
	 */
	private boolean CheckDate1(EditTextWithDate et1, EditTextWithDate et2, EditText et3, EditText et4, EditText et5) {
		if (!TextUtils.isEmpty(et1.getText().toString()) || !TextUtils.isEmpty(et2.getText().toString())
				|| !TextUtils.isEmpty(et3.getText().toString()) || !TextUtils.isEmpty(et4.getText().toString())
				|| !TextUtils.isEmpty(et5.getText().toString())) {
			if (TextUtils.isEmpty(et1.getText().toString()) || TextUtils.isEmpty(et2.getText().toString())
					|| TextUtils.isEmpty(et3.getText().toString()) || TextUtils.isEmpty(et4.getText().toString())
					|| TextUtils.isEmpty(et5.getText().toString())) {
				return true;
			} else {
				return false;
			}
		} else {
			return false;
		}
	}

	/**
	 * 判断主要用药情况是否有缺项值
	 * 
	 * @param et1
	 * @param et2
	 * @param et3
	 * @param rb1
	 * @param rb2
	 * @param rb3
	 * @return true 有缺项值 false 无缺项值
	 */
	private boolean CheckDate2(EditText et1, EditText et2, EditText et3, RadioButtonAdapter adapter) {
		if (!TextUtils.isEmpty(et1.getText().toString()) || !TextUtils.isEmpty(et2.getText().toString())
				|| !TextUtils.isEmpty(et3.getText().toString()) || !TextUtils.isEmpty(adapter.getChecked())) {
			if (TextUtils.isEmpty(et1.getText().toString()) || TextUtils.isEmpty(et2.getText().toString())
					|| TextUtils.isEmpty(et3.getText().toString()) || TextUtils.isEmpty(adapter.getChecked())) {
				return true;
			} else {
				return false;
			}
		} else {
			return false;
		}
	}

	/**
	 * 设置展示的信息
	 * 
	 * @author 王婷婷
	 * @date 2015年12月17日 上午11:31:24
	 */
	private void setShowData() {

		setData_yyqk();
		setData_zys();
		setData_jtzys();
	}

	@Override
	public void save() {
		getRadioButtonCheckedData();
		saveData();

	}

	/**
	 * 设置下拉
	 * 
	 * @param flagName
	 * @param strSql
	 * @author 王婷婷
	 * @date 2015年12月24日 上午9:19:28
	 */
	private void bindSpinner(String flagName, String strSql) {
		List<BD_DD_INFO> sList = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class, strSql);

		if (flagName.equals("用药时间")) {

			Log.w("eeeeeeeeeeeeeee", "ttt---" + sList.size());
			// nice_adapter_yy1_yysj = new NiceSpinnerAdapter<>(getActivity(),
			// sList);
			nice_spinner_yy1_yysj.attachDataSource(lstYy);// setAdapter(nice_adapter_yy1_yysj);

			// nice_adapter_yy2_yysj = new NiceSpinnerAdapter<>(getActivity(),
			// sList);
			nice_spinner_yy2_yysj.attachDataSource(lstYy);

			// nice_adapter_yy3_yysj = new NiceSpinnerAdapter<>(getActivity(),
			// sList);
			nice_spinner_yy3_yysj.attachDataSource(lstYy);

			// nice_adapter_yy4_yysj = new NiceSpinnerAdapter<>(getActivity(),
			// sList);
			nice_spinner_yy4_yysj.attachDataSource(lstYy);

			// nice_adapter_yy5_yysj = new NiceSpinnerAdapter<>(getActivity(),
			// sList);
			nice_spinner_yy5_yysj.attachDataSource(lstYy);

			// nice_adapter_yy6_yysj = new NiceSpinnerAdapter<>(getActivity(),
			// sList);
			nice_spinner_yy6_yysj.attachDataSource(lstYy);
		}
	}

	public int getListIndex(String str, List<String> lst) {
		for (int i = 0; i < lst.size(); i++) {
			if (str.equals(lst.get(i))) {
				return i;
			}
		}
		return 0;
	}

	/**
	 * 用药情况
	 * 
	 * @author 王婷婷
	 * @date 2015年12月24日 下午2:25:11
	 */
	private void setData_yyqk() {
		List<ARCHIVE_MEDICATION> queses = fdbmanger.findAllByWhere(ARCHIVE_MEDICATION.class,
				"IDCARD='" + userInfo.getIDCARD() + "'");
		int size = queses.size();
		if (size > 0) {
			from_yy = 1;
			for (int i = 0; i < size; i++) {
				if (i == 0) {
					ques1_before = queses.get(0);
					ed_yy1_ywmc.setText(ques1_before.getMEDICINALNAME());
					ed_yy1_yf.setText(ques1_before.getUSEAGE());
					ed_yy1_yl.setText(ques1_before.getUSENUM());
					str_yy1_fyycxId = ques1_before.getPILLDEPENDENCE();
					adapter_yy1_fyycx.setChecked(str_yy1_fyycxId);
					nice_spinner_yy1_yysj.setSelectedIndex(getListIndex(ques1_before.getSTARTTIME(), lstYy));
				} else if (i == 1) {
					ques2_before = queses.get(1);
					ed_yy2_ywmc.setText(ques2_before.getMEDICINALNAME());
					ed_yy2_yf.setText(ques2_before.getUSEAGE());
					ed_yy2_yl.setText(ques2_before.getUSENUM());
					str_yy2_fyycxId = ques2_before.getPILLDEPENDENCE();
					adapter_yy2_fyycx.setChecked(str_yy2_fyycxId);

					nice_spinner_yy2_yysj.setSelectedIndex(getListIndex(ques2_before.getSTARTTIME(), lstYy));
				} else if (i == 2) {
					ques3_before = queses.get(2);
					ed_yy3_ywmc.setText(ques3_before.getMEDICINALNAME());
					ed_yy3_yf.setText(ques3_before.getUSEAGE());
					ed_yy3_yl.setText(ques3_before.getUSENUM());
					str_yy3_fyycxId = ques3_before.getPILLDEPENDENCE();
					adapter_yy3_fyycx.setChecked(str_yy3_fyycxId);
					nice_spinner_yy3_yysj.setSelectedIndex(getListIndex(ques3_before.getSTARTTIME(), lstYy));
				} else if (i == 3) {
					ques4_before = queses.get(3);
					ed_yy4_ywmc.setText(ques4_before.getMEDICINALNAME());
					ed_yy4_yf.setText(ques4_before.getUSEAGE());
					ed_yy4_yl.setText(ques4_before.getUSENUM());
					str_yy4_fyycxId = ques4_before.getPILLDEPENDENCE();
					adapter_yy4_fyycx.setChecked(str_yy4_fyycxId);
					nice_spinner_yy4_yysj.setSelectedIndex(getListIndex(ques4_before.getSTARTTIME(), lstYy));
				} else if (i == 4) {
					ques5_before = queses.get(4);
					ed_yy5_ywmc.setText(ques5_before.getMEDICINALNAME());
					ed_yy5_yf.setText(ques5_before.getUSEAGE());
					ed_yy5_yl.setText(ques5_before.getUSENUM());
					str_yy5_fyycxId = ques5_before.getPILLDEPENDENCE();
					adapter_yy5_fyycx.setChecked(str_yy5_fyycxId);
					nice_spinner_yy5_yysj.setSelectedIndex(getListIndex(ques5_before.getSTARTTIME(), lstYy));
				} else if (i == 5) {
					ques6_before = queses.get(5);
					ed_yy6_ywmc.setText(ques6_before.getMEDICINALNAME());
					ed_yy6_yf.setText(ques6_before.getUSEAGE());
					ed_yy6_yl.setText(ques6_before.getUSENUM());
					str_yy6_fyycxId = ques6_before.getPILLDEPENDENCE();
					adapter_yy6_fyycx.setChecked(str_yy6_fyycxId);

					nice_spinner_yy6_yysj.setSelectedIndex(getListIndex(ques6_before.getSTARTTIME(), lstYy));
				}
			}

		} else {
			from_yy = 0;
		}
	}

	/**
	 * 住院史
	 * 
	 * @author 王婷婷
	 * @date 2015年12月24日 下午2:25:03
	 */
	private void setData_zys() {
		List<ARCHIVE_HOSPITALHISTORY> zy = fdbmanger.findAllByWhere(ARCHIVE_HOSPITALHISTORY.class,
				"IDCARD='" + userInfo.getIDCARD() + "'");
		int size_zy = zy.size();
		if (size_zy > 0) {
			from_zy = 1;
			for (int i = 0; i < size_zy; i++) {
				if (i == 0) {
					zy1_before = zy.get(0);
					if (zy1_before.getINHOSPITALDATE() != null) {
						ed_time1_start.setText(dateFormat.format(zy1_before.getINHOSPITALDATE()));
					}
					if (zy1_before.getOUTHOSPITALDATE() != null) {
						ed_time1_end.setText(dateFormat.format(zy1_before.getOUTHOSPITALDATE()));
					}
					ed_time1_result.setText(zy1_before.getREASON());
					ed_time1_yljg.setText(zy1_before.getHOSPITALNAME());

					ed_time1_bah.setText(zy1_before.getILLCASENUM());
				} else if (i == 1) {
					zy2_before = zy.get(1);
					if (zy2_before.getINHOSPITALDATE() != null) {
						ed_time2_start.setText(dateFormat.format(zy2_before.getINHOSPITALDATE()));
					}
					if (zy2_before.getOUTHOSPITALDATE() != null) {
						ed_time2_end.setText(dateFormat.format(zy2_before.getOUTHOSPITALDATE()));
					}
					ed_time2_result.setText(zy2_before.getREASON());
					ed_time2_yljg.setText(zy2_before.getHOSPITALNAME());
					ed_time2_bah.setText(zy2_before.getILLCASENUM());
				}
			}
		} else {
			from_zy = 0;
		}
	}

	/**
	 * 家庭床病史
	 * 
	 * @author 王婷婷
	 * @date 2015年12月24日 下午2:25:03
	 */
	private void setData_jtzys() {
		List<ARCHIVE_FAMILYBEDHISTORY> zy = fdbmanger.findAllByWhere(ARCHIVE_FAMILYBEDHISTORY.class,
				"IDCARD='" + userInfo.getIDCARD() + "'");
		int size_zy = zy.size();
		if (size_zy > 0) {
			from_jtbcs = 1;
			for (int i = 0; i < size_zy; i++) {
				if (i == 0) {
					family_zy1_before = zy.get(0);
					if (family_zy1_before.getINHOSPITALDATE() != null) {
						ed_jt_time1_start.setText(dateFormat.format(family_zy1_before.getINHOSPITALDATE()));
					}
					if (family_zy1_before.getOUTHOSPITALDATE() != null) {
						ed_jt_time1_end.setText(dateFormat.format(family_zy1_before.getOUTHOSPITALDATE()));
					}
					ed_jt_time1_result.setText(family_zy1_before.getREASONS());
					ed_jt_time1_yljg.setText(family_zy1_before.getHOSPITALNAME());

					ed_jt_time1_bah.setText(family_zy1_before.getILLCASENUMS());
				} else if (i == 1) {
					family_zy2_before = zy.get(1);
					if (family_zy2_before.getINHOSPITALDATE() != null) {
						ed_jt_time2_start.setText(dateFormat.format(family_zy2_before.getINHOSPITALDATE()));
					}
					if (family_zy2_before.getOUTHOSPITALDATE() != null) {
						ed_jt_time2_end.setText(dateFormat.format(family_zy2_before.getOUTHOSPITALDATE()));
					}
					ed_jt_time2_result.setText(family_zy2_before.getREASONS());
					ed_jt_time2_yljg.setText(family_zy2_before.getHOSPITALNAME());
					ed_jt_time2_bah.setText(family_zy2_before.getILLCASENUMS());
				}
			}
		} else {
			from_jtbcs = 0;
		}
	}

	/**
	 * 保存住院史
	 * 
	 * @author 王婷婷
	 * @date 2015年12月24日 下午2:26:06
	 */
	private void save_zys() {

		// 住院史
		ARCHIVE_HOSPITALHISTORY zy1 = new ARCHIVE_HOSPITALHISTORY();
		zy1.setIDCARD(userInfo.getIDCARD());

		String str_ed_time1_start = ed_time1_start.getText().toString();
		if (!TextUtils.isEmpty(str_ed_time1_start)) {
			try {
				zy1.setINHOSPITALDATE((Date) dateFormat.parse(str_ed_time1_start));
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}

		String str_ed_time1_end = ed_time1_end.getText().toString();
		if (!TextUtils.isEmpty(str_ed_time1_end)) {
			try {
				zy1.setOUTHOSPITALDATE((Date) dateFormat.parse(str_ed_time1_end));
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		zy1.setREASON(ed_time1_result.getText().toString());
		zy1.setHOSPITALNAME(ed_time1_yljg.getText().toString());
		zy1.setILLCASENUM(ed_time1_bah.getText().toString());

		// 住院史
		ARCHIVE_HOSPITALHISTORY zy2 = new ARCHIVE_HOSPITALHISTORY();
		zy2.setIDCARD(userInfo.getIDCARD());

		String str_ed_time2_start = ed_time2_start.getText().toString();
		if (!TextUtils.isEmpty(str_ed_time2_start)) {
			try {
				zy2.setINHOSPITALDATE((Date) dateFormat.parse(str_ed_time2_start));
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		String str_ed_time2_end = ed_time2_end.getText().toString();
		if (!TextUtils.isEmpty(str_ed_time2_end)) {
			try {
				zy2.setOUTHOSPITALDATE((Date) dateFormat.parse(str_ed_time2_end));
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		zy2.setREASON(ed_time2_result.getText().toString());
		zy2.setHOSPITALNAME(ed_time2_yljg.getText().toString());
		zy2.setILLCASENUM(ed_time2_bah.getText().toString());

		if (from_zy == 1) {
			zy1.setUPDATEORG(userInfo.getCREATEORG());
			zy1.setMODIFIED(userInfo.getCREATER());
			zy2.setUPDATEORG(userInfo.getCREATEORG());
			zy2.setMODIFIED(userInfo.getCREATER());
			// 一样 true
			if (!zy1.equals(zy1_before)) {
				zy1.setNGUID(UUID.randomUUID().toString());
				fdbmanger.updata(zy1, "IDCARD='" + userInfo.getIDCARD() + "' and ID=1");
				zy1_before = zy1;
			}

			if (!zy2.equals(zy2_before)) {
				zy2.setNGUID(UUID.randomUUID().toString());
				fdbmanger.updata(zy2, "IDCARD='" + userInfo.getIDCARD() + "' and ID=2");
				zy2_before = zy2;
			}
			((TiJianActivity) getActivity()).showTextDialog("修改成功");

		} else if (from_zy == 0) {
			zy1.setCREATEORG(userInfo.getCREATEORG());
			zy1.setCREATER(userInfo.getCREATER());
			zy2.setCREATEORG(userInfo.getCREATEORG());
			zy2.setCREATER(userInfo.getCREATER());
			// 一样 true
			zy1.setNGUID(UUID.randomUUID().toString());
			fdbmanger.save(zy1);

			zy2.setNGUID(UUID.randomUUID().toString());
			fdbmanger.save(zy2);
			((TiJianActivity) getActivity()).showTextDialog("保存成功");
			from_zy = 1;
			zy1_before = zy1;
			zy2_before = zy2;
		}
	}

	/**
	 * 保存 家庭病床史
	 * 
	 * @author 王婷婷
	 * @date 2015年12月24日 下午2:26:06
	 */
	private void save_jtbcs() {

		// 家庭病床
		ARCHIVE_FAMILYBEDHISTORY zy1 = new ARCHIVE_FAMILYBEDHISTORY();
		zy1.setIDCARD(userInfo.getIDCARD());

		String str_ed_time1_start = ed_jt_time1_start.getText().toString();
		if (!TextUtils.isEmpty(str_ed_time1_start)) {
			try {
				zy1.setINHOSPITALDATE((Date) dateFormat.parse(str_ed_time1_start));
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		String str_ed_time1_end = ed_jt_time1_end.getText().toString();
		if (!TextUtils.isEmpty(str_ed_time1_end)) {
			try {
				zy1.setOUTHOSPITALDATE((Date) dateFormat.parse(str_ed_time1_end));
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		zy1.setREASONS(ed_jt_time1_result.getText().toString());
		zy1.setHOSPITALNAME(ed_jt_time1_yljg.getText().toString());
		zy1.setILLCASENUMS(ed_jt_time1_bah.getText().toString());

		// 病床史
		ARCHIVE_FAMILYBEDHISTORY zy2 = new ARCHIVE_FAMILYBEDHISTORY();
		zy2.setIDCARD(userInfo.getIDCARD());

		String str_ed_time2_start = ed_jt_time2_start.getText().toString();
		if (!TextUtils.isEmpty(str_ed_time2_start)) {
			try {
				zy2.setINHOSPITALDATE((Date) dateFormat.parse(str_ed_time2_start));
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		String str_ed_time2_end = ed_jt_time2_end.getText().toString();
		if (!TextUtils.isEmpty(str_ed_time2_end)) {
			try {
				zy2.setOUTHOSPITALDATE((Date) dateFormat.parse(str_ed_time2_end));
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		zy2.setREASONS(ed_jt_time2_result.getText().toString());
		zy2.setHOSPITALNAME(ed_jt_time2_yljg.getText().toString());
		zy2.setILLCASENUMS(ed_jt_time2_bah.getText().toString());

		if (from_jtbcs == 1) {
			zy1.setUPDATEORG(userInfo.getCREATEORG());
			zy1.setMODIFIED(userInfo.getCREATER());
			zy2.setUPDATEORG(userInfo.getCREATEORG());
			zy2.setMODIFIED(userInfo.getCREATER());

			// 一样 true
			if (!zy1.equals(family_zy1_before)) {
				zy1.setNGUID(UUID.randomUUID().toString());
				fdbmanger.updata(zy1, "IDCARD='" + userInfo.getIDCARD() + "' and ID=1");
				family_zy1_before = zy1;

			}

			if (!zy2.equals(family_zy2_before)) {
				zy2.setNGUID(UUID.randomUUID().toString());
				fdbmanger.updata(zy2, "IDCARD='" + userInfo.getIDCARD() + "' and ID=2");
				family_zy2_before = zy2;
			}

			((TiJianActivity) getActivity()).showTextDialog("修改成功");
		} else if (from_jtbcs == 0) {
			zy1.setCREATEORG(userInfo.getCREATEORG());
			zy1.setCREATER(userInfo.getCREATER());
			zy2.setCREATEORG(userInfo.getCREATEORG());
			zy2.setCREATER(userInfo.getCREATER());
			zy1.setNGUID(UUID.randomUUID().toString());
			zy2.setNGUID(UUID.randomUUID().toString());
			fdbmanger.save(zy1);
			fdbmanger.save(zy2);
			((TiJianActivity) getActivity()).showTextDialog("保存成功");
			from_jtbcs = 1;
			family_zy1_before = zy1;
			family_zy2_before = zy2;

		}
	}

	/**
	 * 保存用药情况
	 * 
	 * @author 王婷婷
	 * @date 2015年12月24日 下午2:28:24
	 */
	private void save_yyqk() {
		// 用药情况
		ARCHIVE_MEDICATION ques1 = new ARCHIVE_MEDICATION();

		ques1.setIDCARD(userInfo.getIDCARD());
		ques1.setMEDICINALNAME(ed_yy1_ywmc.getText().toString());
		ques1.setUSEAGE(ed_yy1_yf.getText().toString());
		ques1.setUSENUM(ed_yy1_yl.getText().toString());
		ques1.setPILLDEPENDENCE(str_yy1_fyycxId);
		
		// 设置 服用时间
		int nice_spinner_yy1_yysj_pos = nice_spinner_yy1_yysj.getSelectedIndex();
		Log.w("dddddddddnice_spinner_culture_pos1", "tt--" + nice_spinner_yy1_yysj_pos);

		ques1.setSTARTTIME(lstYy.get(nice_spinner_yy1_yysj.getSelectedIndex()));
		// --------------------------------------2--------------------------------------
		// 用药情况
		ARCHIVE_MEDICATION ques2 = new ARCHIVE_MEDICATION();

		ques2.setIDCARD(userInfo.getIDCARD());
		ques2.setMEDICINALNAME(ed_yy2_ywmc.getText().toString());
		ques2.setUSEAGE(ed_yy2_yf.getText().toString());
		ques2.setUSENUM(ed_yy2_yl.getText().toString());
		ques2.setPILLDEPENDENCE(str_yy2_fyycxId);

		// 设置 服用时间
		int nice_spinner_yy2_yysj_pos = nice_spinner_yy2_yysj.getSelectedIndex();
		Log.w("dddddddddnice_spinner_culture_pos2", "tt--" + nice_spinner_yy2_yysj_pos);

		ques2.setSTARTTIME(lstYy.get(nice_spinner_yy2_yysj.getSelectedIndex()));
		// --------------------------------------3--------------------------------------
		ARCHIVE_MEDICATION ques3 = new ARCHIVE_MEDICATION();

		ques3.setIDCARD(userInfo.getIDCARD());
		ques3.setMEDICINALNAME(ed_yy3_ywmc.getText().toString());
		ques3.setUSEAGE(ed_yy3_yf.getText().toString());
		ques3.setUSENUM(ed_yy3_yl.getText().toString());
		ques3.setPILLDEPENDENCE(str_yy3_fyycxId);

		// 设置 服用时间
		int nice_spinner_yy3_yysj_pos = nice_spinner_yy3_yysj.getSelectedIndex();
		Log.w("dddddddddnice_spinner_culture_pos3", "tt--" + nice_spinner_yy3_yysj_pos);

		ques3.setSTARTTIME(lstYy.get(nice_spinner_yy3_yysj.getSelectedIndex()));
		// --------------------------------------4--------------------------------------
		// 用药情况
		ARCHIVE_MEDICATION ques4 = new ARCHIVE_MEDICATION();

		ques4.setIDCARD(userInfo.getIDCARD());
		ques4.setMEDICINALNAME(ed_yy4_ywmc.getText().toString());
		ques4.setUSEAGE(ed_yy4_yf.getText().toString());
		ques4.setUSENUM(ed_yy4_yl.getText().toString());
		ques4.setPILLDEPENDENCE(str_yy4_fyycxId);

		// 设置 服用时间
		int nice_spinner_yy4_yysj_pos = nice_spinner_yy4_yysj.getSelectedIndex();
		Log.w("dddddddddnice_spinner_culture_pos4", "tt--" + nice_spinner_yy4_yysj_pos);

		ques4.setSTARTTIME(lstYy.get(nice_spinner_yy4_yysj.getSelectedIndex()));
		// --------------------------------------5--------------------------------------
		// 用药情况
		ARCHIVE_MEDICATION ques5 = new ARCHIVE_MEDICATION();

		ques5.setIDCARD(userInfo.getIDCARD());
		ques5.setMEDICINALNAME(ed_yy5_ywmc.getText().toString());
		ques5.setUSEAGE(ed_yy5_yf.getText().toString());
		ques5.setUSENUM(ed_yy5_yl.getText().toString());
		ques5.setPILLDEPENDENCE(str_yy5_fyycxId);

		// 设置 服用时间
		int nice_spinner_yy5_yysj_pos = nice_spinner_yy5_yysj.getSelectedIndex();
		Log.w("dddddddddnice_spinner_culture_pos5", "tt--" + nice_spinner_yy5_yysj_pos);

		ques5.setSTARTTIME(lstYy.get(nice_spinner_yy5_yysj.getSelectedIndex()));
		// --------------------------------------6--------------------------------------

		// 用药情况
		ARCHIVE_MEDICATION ques6 = new ARCHIVE_MEDICATION();

		ques6.setIDCARD(userInfo.getIDCARD());
		ques6.setMEDICINALNAME(ed_yy6_ywmc.getText().toString());
		ques6.setUSEAGE(ed_yy6_yf.getText().toString());
		ques6.setUSENUM(ed_yy6_yl.getText().toString());
		ques6.setPILLDEPENDENCE(str_yy6_fyycxId);

		// 设置 服用时间
		int nice_spinner_yy6_yysj_pos = nice_spinner_yy6_yysj.getSelectedIndex();
		Log.w("dddddddddnice_spinner_culture_pos6", "tt--" + nice_spinner_yy6_yysj_pos);

		ques6.setSTARTTIME(lstYy.get(nice_spinner_yy6_yysj.getSelectedIndex()));

		// --------------

		if (from_yy == 1) {
			// 一样 true
			if (!ques1.equals(ques1_before)) {
				ques1.setNGUID(UUID.randomUUID().toString());
				if (!TextUtils.isEmpty(ed_yy1_ywmc.getText().toString())) {
					fdbmanger.updata(ques1, "IDCARD='" + userInfo.getIDCARD() + "' and ID=1");
				}
				ques1_before = ques1;

			}

			if (!ques2.equals(ques2_before)) {
				ques2.setNGUID(UUID.randomUUID().toString());
				if (!TextUtils.isEmpty(ed_yy2_ywmc.getText().toString())) {
					fdbmanger.updata(ques2, "IDCARD='" + userInfo.getIDCARD() + "' and ID=2");
				}
				ques2_before = ques2;

			}
			if (!ques3.equals(ques3_before)) {
				ques3.setNGUID(UUID.randomUUID().toString());
				if (!TextUtils.isEmpty(ed_yy3_ywmc.getText().toString())) {
					fdbmanger.updata(ques3, "IDCARD='" + userInfo.getIDCARD() + "' and ID=3");
				}
				ques3_before = ques3;

			}
			if (!ques4.equals(ques4_before)) {
				ques4.setNGUID(UUID.randomUUID().toString());
				if (!TextUtils.isEmpty(ed_yy4_ywmc.getText().toString())) {
					fdbmanger.updata(ques4, "IDCARD='" + userInfo.getIDCARD() + "' and ID=4");
				}
				ques4_before = ques4;

			}
			if (!ques5.equals(ques5_before)) {
				ques5.setNGUID(UUID.randomUUID().toString());
				if (!TextUtils.isEmpty(ed_yy5_ywmc.getText().toString())) {
					fdbmanger.updata(ques5, "IDCARD='" + userInfo.getIDCARD() + "' and ID=5");
				}
				ques5_before = ques5;

			}
			if (!ques6.equals(ques6_before)) {
				ques6.setNGUID(UUID.randomUUID().toString());
				if (!TextUtils.isEmpty(ed_yy6_ywmc.getText().toString())) {
					fdbmanger.updata(ques6, "IDCARD='" + userInfo.getIDCARD() + "' and ID=6");
				}
				ques6_before = ques6;
			}

			((TiJianActivity) getActivity()).showTextDialog("修改成功");
		} else if (from_yy == 0) {
			ques1.setNGUID(UUID.randomUUID().toString());
			ques2.setNGUID(UUID.randomUUID().toString());
			ques3.setNGUID(UUID.randomUUID().toString());
			ques4.setNGUID(UUID.randomUUID().toString());
			ques5.setNGUID(UUID.randomUUID().toString());
			ques6.setNGUID(UUID.randomUUID().toString());

			if (!TextUtils.isEmpty(ed_yy1_ywmc.getText().toString())) {
				fdbmanger.save(ques1);
			}
			if (!TextUtils.isEmpty(ed_yy2_ywmc.getText().toString())) {
				
				fdbmanger.save(ques2);
			}
			if (!TextUtils.isEmpty(ed_yy3_ywmc.getText().toString())) {
				
				fdbmanger.save(ques3);
			}
			if (!TextUtils.isEmpty(ed_yy4_ywmc.getText().toString())) {
				
				fdbmanger.save(ques4);
			}
			if (!TextUtils.isEmpty(ed_yy5_ywmc.getText().toString())) {
				
				fdbmanger.save(ques5);
			}
			if (!TextUtils.isEmpty(ed_yy6_ywmc.getText().toString())) {
				
				fdbmanger.save(ques6);
			}
			((TiJianActivity) getActivity()).showTextDialog("保存成功");
			from_yy = 1;

			ques1_before = ques1;
			ques2_before = ques2;
			ques3_before = ques3;
			ques4_before = ques4;
			ques5_before = ques5;
			ques6_before = ques6;
		}

	}
}
